
import { defineStore } from 'pinia'

// 加载动画
export const useLoadingStore = defineStore('loading', {
  state: () => ({
    isLoading: false,
  }),
  actions: {
    show() {
      this.isLoading = true

      setTimeout(() => {
        this.isLoading = false
      }, 5000);
    },
    hide() {
      setTimeout(() => {
        this.isLoading = false
      }, 100); // 放置状态变化过快检测不到
    }
  }
})

// 是否是黑暗模式
export const systemStatus = defineStore('systemStatus', {
  state: () => ({
    isDark: false,
  }),
  actions: {
    changeStatus() {
      this.isDark = !this.isDark
    },
  }
})

// 管理端面板是否折叠
export const managePanel = defineStore('managePanel', {
  state: () => ({
    isCollapse: false,
  }),
  actions: {
    toggleCollapse() {
      this.isCollapse = !this.isCollapse
    },
  }
})

// 文章的目录是否展开
export const articlesStatus = defineStore('articlesStatus', {
  state: () => ({
    ArticleCatalog: false,
  }),
  actions: {
    toggleCollapse() {
      this.ArticleCatalog = !this.ArticleCatalog
    },
  }
})

// 动态的评论列表是否展开  加载动态评论的id，当点击时传送文章id，评论读取id加载
export const dynamicCommentStatus = defineStore('dynamicCommentStatus', {
  state: () => ({
    isOpen: false,
  }),
  actions: {
    toggle() {
      this.isOpen = !this.isOpen
    },
  }
})
